package P5.T04;

import javax.swing.*;
import java.awt.*;

public class MyJFrame2 extends JFrame {
    public MyJFrame2() {
        this.setTitle("MyJFrame2");
//        getContentPane().setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
        Box hbox = Box.createHorizontalBox();
        JButton lblName=new JButton("用户名");
        lblName.setSize(10,100);
        TextField tfName=new TextField(10);
        tfName.setSize(10,100);
//        tfName.setVisible(false);
        tfName.setEnabled(false);
        hbox.add(lblName);
        Component c=Box.createHorizontalStrut(2);
        hbox.add(c);
        hbox.add(tfName);
        add(hbox);
        getContentPane().setBackground(Color.blue);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(500, 500);
        this.setLocationRelativeTo(null);
        this.setVisible(true);

    }
}
